package org.mydzms.com.controller;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;





import org.dzms.entity.FoodDetails;
import org.dzms.services.FoodDetailsService;
import org.dzms.services.foodClassService;


/**
 * Servlet implementation class FoodDetailsServlet
 */
public class FoodDetailsServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doPost(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String fdid = request.getParameter("fdid");
		
//		FoodDetails fdx = new FoodDetails();
//		fdx.setFdid(Integer.parseInt(fdid));
//			if(fdid==null){
//				fdid="1";
//			}
		
			FoodDetailsService fds = new FoodDetailsService();
			request.setAttribute("fs", fds.findFdId(Integer.parseInt(fdid)));
//			request.getRequestDispatcher("foodDetails.jsp").forward(request, response);
		
//			String fdid = request.getParameter("fdid");
//			FoodDetailsService fs = new FoodDetailsService();
//			request.setAttribute("fs", fs.findFdId("fdid="+fdid).get(0));
//			request.getRequestDispatcher("foodDetails.jsp").forward(request, response);
			
			request.setAttribute("fes", fds.findAllFess());
		
		String cp = request.getParameter("cp")==null?"1":request.getParameter("cp");
		String cond = request.getParameter("cond")==null?" ":request.getParameter("cond");
		FoodDetailsService fd = new FoodDetailsService();
		request.setAttribute("fd", fd.findPage(Integer.parseInt(cp), cond));
//		request.setAttribute("fdd", fd.findAllUrs());
		request.getRequestDispatcher("foodDetails.jsp").forward(request, response);

	}
}
